﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:appStyles="clr-namespace:Abreu.Base"
                    xmlns:local="clr-namespace:CorpAbreu.Common.BaseClasses;assembly=CorpAbreu.Common">
    <ControlTemplate x:Key="OutlookTab" TargetType="{x:Type TabControl}">
        <ControlTemplate.Resources>
            <!-- To change the colour scheme of the Outlook Bar, change the colors of these brushes -->
            <SolidColorBrush x:Key="LabelHighlightBrush" Color= "#FFFFFF" />
            <SolidColorBrush x:Key="CaptionBrush" Color= "#15428B" />
            <SolidColorBrush x:Key="BorderBrush" Color="#6593CF" />
            <LinearGradientBrush x:Key="LabelBrush" StartPoint="0, 0" EndPoint="0,1">
                <GradientStop Color="#E3EFFF" Offset="0" />
                <GradientStop Color="#AFD2FF" Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="ButtonNormalBrush" StartPoint="0, 0" EndPoint="0,1">
                <GradientStop Color="#E3EFFF" Offset="0" />
                <GradientStop Color="#C4DDFF" Offset="0.40625" />
                <GradientStop Color="#ADD1FF" Offset="0.40625" />
                <GradientStop Color="#C0DBFF" Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="ButtonSelectedBrush" StartPoint="0, 0" EndPoint="0,1">
                <GradientStop Color="#FFD9AA" Offset="0" />
                <GradientStop Color="#FFBB6E" Offset="0.40625" />
                <GradientStop Color="#FFAB3F" Offset="0.40625" />
                <GradientStop Color="#FEE17A" Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="ButtonPressedBrush" StartPoint="0, 0" EndPoint="0,1">
                <GradientStop Color="#FFBD69" Offset="0" />
                <GradientStop Color="#FFAC42" Offset="0.40625" />
                <GradientStop Color="#FB8C3C" Offset="0.40625" />
                <GradientStop Color="#FED364" Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="ButtonHoverBrush" StartPoint="0, 0" EndPoint="0,1">
                <GradientStop Color="#FFFEE4" Offset="0" />
                <GradientStop Color="#FFE8A7" Offset="0.40625" />
                <GradientStop Color="#FFD767" Offset="0.40625" />
                <GradientStop Color="#FFE69E" Offset="1" />
            </LinearGradientBrush>
            <!-- This style sets the default template for a TabItem -->
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <!-- These triggers control the background and text colour of the Outlook bar buttons when the are selected and/or hovered over -->
                            <ControlTemplate.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="False" />
                                        <Condition Property="IsMouseOver" Value="False" />
                                    </MultiTrigger.Conditions>
                                    <MultiTrigger.Setters>
                                        <Setter Property="Background" Value="{StaticResource ButtonNormalBrush}" />
                                    </MultiTrigger.Setters>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="False" />
                                        <Condition Property="IsMouseOver" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <MultiTrigger.Setters>
                                        <Setter Property="Background" Value="{StaticResource ButtonHoverBrush}" />
                                    </MultiTrigger.Setters>
                                </MultiTrigger>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="TextElement.Foreground" Value="Black" />
                                    <Setter Property="Background" Value="{StaticResource ButtonSelectedBrush}" />
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter Property="TextElement.Foreground" Value="{StaticResource CaptionBrush}" />
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="True" />
                                        <Condition Property="IsMouseOver" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <MultiTrigger.Setters>
                                        <Setter Property="Background" Value="{StaticResource ButtonPressedBrush}" />
                                    </MultiTrigger.Setters>
                                </MultiTrigger>
                            </ControlTemplate.Triggers>
                            <!-- This defines the look of the individual TabItems -->
                            <Grid Background="{TemplateBinding Background}" MinHeight="32" SnapsToDevicePixels="True">
                                <Line Stroke="{StaticResource BorderBrush}" VerticalAlignment="Top" Stretch="Fill" X2="1" SnapsToDevicePixels="True" />
                                <ContentPresenter Margin="5,0,5,0" TextBlock.FontFamily="Tahoma" TextBlock.FontSize="8pt" TextBlock.FontWeight="Bold" TextBlock.Foreground="{StaticResource CaptionBrush}" Content="{TemplateBinding Header}" VerticalAlignment="Center"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ControlTemplate.Resources>
        <!-- This is the template for the TabControl itself -->
        <Border BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" >
            <DockPanel>
                <!-- This is the host panel that contains the tab items -->
                <StackPanel DockPanel.Dock="Bottom" IsItemsHost="True" />
                <!-- This is the label that appears at the top of the TabControl -->
                <Grid DockPanel.Dock="Top" MinHeight="28" Background="{StaticResource ButtonNormalBrush}"  SnapsToDevicePixels="True">
                    <ContentPresenter TextBlock.FontFamily="Tahoma" TextBlock.Foreground="{StaticResource CaptionBrush}" 
                    VerticalAlignment="Center" Margin="5,0" TextBlock.FontSize="18" TextBlock.FontWeight="Bold" 
                    Content="{Binding RelativeSource={RelativeSource AncestorType=TabControl}, Path=SelectedItem.Header}" />                    
                    <Line Stroke="{StaticResource BorderBrush}" VerticalAlignment="Bottom" X2="1" Stretch="Fill" />
                </Grid>
                <!-- This is the selected content pane that appears in the Outlook Bar -->
                <ContentPresenter Content="{TemplateBinding SelectedContent}" />
            </DockPanel>
        </Border>
    </ControlTemplate>
    <ControlTemplate x:Key="TextBoxErrorTemplate" TargetType="Control">
        <ControlTemplate.Resources>
            <BitmapImage x:Key="ErrorImage" UriSource="error.png" />
        </ControlTemplate.Resources>
        <Grid ClipToBounds="False" >
            <Image HorizontalAlignment="Right" VerticalAlignment="Center" 
               Width="16" Height="16" Margin="0,0,0,0" 
               Source="{StaticResource ErrorImage}" 
               ToolTip="{Binding ElementName=adornedElement, 
                         Path=AdornedElement.(Validation.Errors), 
                         Converter={local:ValidationErrorsToStringConverter}}"/>
            <Border BorderBrush="Red" BorderThickness="1" Margin="-1">
                <AdornedElementPlaceholder Name="adornedElement" />
            </Border>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="ComboBoxErrorTemplate" TargetType="Control">
        <ControlTemplate.Resources>
            <BitmapImage x:Key="ErrorImage" UriSource="error.png" />
        </ControlTemplate.Resources>
        <Grid ClipToBounds="False" >
            <Image HorizontalAlignment="Left" VerticalAlignment="Center" 
               Width="16" Height="16" Margin="0,0,0,0" 
               Source="{StaticResource ErrorImage}" 
               ToolTip="{Binding ElementName=adornedElement, 
                         Path=AdornedElement.(Validation.Errors), 
                         Converter={local:ValidationErrorsToStringConverter}}"/>
            <Border BorderBrush="Red" BorderThickness="1" Margin="-1">
                <AdornedElementPlaceholder Name="adornedElement" />
            </Border>
        </Grid>
    </ControlTemplate>
</ResourceDictionary>